<?php /* Smarty version 2.6.20, created on 2016-07-19 18:03:06
         compiled from promote.htm */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'date_format', 'promote.htm', 107, false),array('modifier', 'default', 'promote.htm', 117, false),array('function', 'html_select_time', 'promote.htm', 108, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>促销管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
<script>
function showProductIds(proIds){
	var html = "<textarea style='width:600px;height:300px;' readonly>"+proIds+"</textarea>";
	window.parent.html_form('productId','商品ID',html,600);
}
$(function(){
	$('#form').submit(function(){
        if (!$('#sku_id').val()) {
            alert('请选择商品');
            return false;
        };
    }).validate({
		errorPlacement: function(error, element){
			element.next('.form-error').append(error);
		},      
		rules : {
			stime:{
				required:true
			},
			etime:{
				required:true
			},
			sec_total:{
				required:true
			},
			sec_limit:{
				required:true
			},
			sec_price:{
				required:true
			}
		},
		messages : {
			etime:{
				required:'请填写开始时间',
			},
			stime:{
				required:'请填写结束时间',
			},
			sec_total:{
				required:'请填写促销总数',
			},
			sec_limit:{
				required:'请填写最多可买',
			},
			sec_price:{
				required:'请填写促销价格'
			}
		}
	});
});


                    var cdr = new Calendar("cdr");
                    document.write(cdr);
                    cdr.showMoreDay = true;
                    </script>

</head>
<body>
        <div class="flow">
            <div class="itemtitle">
                <h3>促销管理</h3>
                <ul>
                    <li <?php if ($_GET['operation'] == ''): ?>class="current"<?php endif; ?>><a href="?m=activity&s=promote.php"><span>管理</span></a></li>
                    <li <?php if ($_GET['operation'] == 'add'): ?>class="current"<?php endif; ?>><a href="?m=activity&s=promote.php&operation=add"><span>添加</span></a></li>
                    <?php if ($_GET['operation'] == 'edit'): ?>
                    <li class="current"><a href="#"><span>修改</span></a></li>
                    <?php endif; ?>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <div class="container">
        <?php if ($_GET['operation'] == 'add' || $_GET['operation'] == 'edit'): ?>
        
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" value="<?php echo $this->_tpl_vars['de']['id']; ?>
">
            <input name="pid" type="hidden" id="pid" value="<?php echo $this->_tpl_vars['de']['pid']; ?>
">
            <input name="sku_id" type="hidden" id="sku_id" value="<?php echo $this->_tpl_vars['de']['sku_id']; ?>
">
            <table class="table">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">添加促销产品</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">促销产品</td>
                    <td>
                    <span id="pro_title"><?php echo $this->_tpl_vars['de']['pname']; ?>
</span><input type="button" name="" value="选择" id="choosePro">
                    </td>
                </tr>
                <tr>
                    <td>起止时间</td>
                    <td>
                    
                    <input onFocus="cdr.show(this);" class="ltext" type="text" name="stime" id="stime" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['de']['start_time'])) ? $this->_run_mod_handler('date_format', true, $_tmp) : smarty_modifier_date_format($_tmp)); ?>
"> 
                    <?php echo smarty_function_html_select_time(array('use_24_hours' => true,'display_seconds' => false,'display_minutes' => false,'prefix' => 'start','time' => $this->_tpl_vars['de']['start_time']), $this);?>
:00:00
                    - 
                    <input onFocus="cdr.show(this);" class="rtext" type="text" name="etime" id="etime" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['de']['end_time'])) ? $this->_run_mod_handler('date_format', true, $_tmp) : smarty_modifier_date_format($_tmp)); ?>
">
                    <?php echo smarty_function_html_select_time(array('use_24_hours' => true,'display_seconds' => false,'display_minutes' => false,'prefix' => 'end','time' => $this->_tpl_vars['de']['end_time']), $this);?>
:59:59
                    </td>
                </tr>
                <tr>
                    <td width="100">显示总数</td>
                    <td>
                    <input name="sec_total" id="sec_total" type="text"  value="<?php echo ((is_array($_tmp=@$this->_tpl_vars['de']['sec_total'])) ? $this->_run_mod_handler('default', true, $_tmp, 50) : smarty_modifier_default($_tmp, 50)); ?>
"> 前台展示数量<div  class="form-error"></div>
                    </td>
                </tr>
                 <tr>
                    <td width="100">促销库存</td>
                    <td>
                    <input name="sec_true_stock" id="sec_true_stock" type="text"  value="<?php echo $this->_tpl_vars['de']['sec_true_stock']; ?>
"> 不可设定超过库存值（剩余<?php echo ((is_array($_tmp=@$this->_tpl_vars['de']['sec_stock'])) ? $this->_run_mod_handler('default', true, $_tmp, '?') : smarty_modifier_default($_tmp, '?')); ?>
）当前库存：<span id="stocks"><?php echo $this->_tpl_vars['de']['stock']; ?>
</span><div  class="form-error"></div>
                    </td>
                </tr>
                <tr>
                    <td width="100">最多可买</td>
                    <td>
                    <input name="sec_limit" id="sec_limit" type="text"  value="<?php echo ((is_array($_tmp=@$this->_tpl_vars['de']['sec_limit'])) ? $this->_run_mod_handler('default', true, $_tmp, 1) : smarty_modifier_default($_tmp, 1)); ?>
"> 默认为 1 ，0为不限制<div  class="form-error"></div>
                    </td>
                </tr>
                <tr>
                    <td width="100">促销价格</td>
                    <td>
                    <input name="sec_price" id="sec_price" type="text"  value="<?php echo $this->_tpl_vars['de']['sec_price']; ?>
"><div  class="form-error"></div>海欧价:(<span id="price"><?php echo $this->_tpl_vars['de']['price']; ?>
</span>) 市场价:(<span id="market_price"><?php echo $this->_tpl_vars['de']['market_price']; ?>
</span>)
                    </td>
                </tr>
                
                <tr>
                    <td>开启</td>
                    <td>
                    <input type="radio" name="status" value="1" id="open" <?php if ($this->_tpl_vars['de']['status'] == 1 || ! $_GET['editid']): ?>checked="checked"<?php endif; ?>/><label for="open">是</label>
                    <input type="radio" name="status" value="0" id="close" <?php if ($this->_tpl_vars['de']['status'] == 0 && $_GET['editid']): ?>checked="checked"<?php endif; ?>/><label for="close">否</label>
                    </td>
                </tr>
                
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<?php if (! $_GET['editid']): ?>save<?php else: ?>edit<?php endif; ?>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
           
    <script>
$('#choosePro').click(function(){
    window.parent.iframe_form("activity", '促销产品添加', '<?php echo $this->_tpl_vars['config']['weburl']; ?>
/admin/module.php?m=activity&s=promote_product.php&id=<?php echo $_GET['editid']; ?>
&spikeid=spikeid', 800, 530);
    return false;
});

function setProName(str){

    var s= str.split(',');

    $('#pro_title').text(s[2]);

   $('#pid').val(s[1]);
   $('#sku_id').val(s[0]);
   $('#price').text(s[3]);
   $('#market_price').text(s[4]);
   $('#stocks').text(s[5]);


}


</script>
        <?php else: ?>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        
        <table class="table">
        	<thead>
                <tr>
                <form action="" method="get">
                <input type="hidden" name="m" value="activity">
    <input type="hidden" name="s" value="promote.php">
                    <th class="partition" colspan="99">促销产品列表

<span style="float:right;">
<label>产品ID:</label><textarea name="product_id" style="resize:horizontal;height:18px;float:left;"><?php echo $_GET['product_id']; ?>
</textarea>
   <label style="margin-left:20px;">状态:</label><select name="status" style="float:left;">
   <option value="">全部</option>
    <option value="1" <?php if ('1' === $_GET['status']): ?>selected="selected"<?php endif; ?>>开启</option>
    <option value="0" <?php if ('0' === $_GET['status']): ?>selected="selected"<?php endif; ?>>关闭</option>
</select>
<label style="margin-left:20px;">促销日期:</label><input id="sdate" name="sdate" style="float:left;" type="text" size="12" value="<?php echo $_GET['sdate']; ?>
"onFocus="cdr.show(this);" /><label>-</label>
                    <input id="edate" name="edate" style="float:left;" type="text" size="12" value="<?php echo $_GET['edate']; ?>
" onFocus="cdr.show(this);" />

                    <label style="margin-left:20px;">促销状态:</label>
<select name="is_start" style="float:left;">
   <option value="">全部</option>
    <option value="1" <?php if ('1' === $_GET['is_start']): ?>selected="selected"<?php endif; ?>>进行中</option>
    <option value="2" <?php if ('2' === $_GET['is_start']): ?>selected="selected"<?php endif; ?>>未开始</option>
    <option value="-1" <?php if ("-1" === $_GET['is_start']): ?>selected="selected"<?php endif; ?>>已结束</option>
</select>
<label style="margin-left:20px;"><input type="image" src="<?php echo $this->_tpl_vars['config']['weburl']; ?>
/image/admin/search.gif" /></label>


</span>
                    </th>
</form>
                </tr>
            </thead>
            <form action="" method="post">
            <tbody>            
                <tr class="header">
                    <th width="20"></th>
                    <th width="20">产品ID</th>
                    <th width="20">skuID</th>
                    <th width="20"></th>
                    <th width="100">产品名称</th>
                     <th width="20">规格</th>
                    <th width="83">起止时间</th>
                    <th width="100">产品分类</th>
                    <th width="40" style="text-align:center">促销价</th>
                    <th width="40" style="text-align:center">海欧原价</th>
                    <th width="40" style="text-align:center">市场价</th>
                    <th width="20" style="text-align:center">显示总数</th>
                    <th width="20" style="text-align:center">促销库存</th>
                    <th width="20" style="text-align:center">剩余</th>
                    <th width="20" style="text-align:center">最多可买</th>
                    <th width="20" style="text-align:center">状态</th>
                    <th width="30">操作</th>
                </tr>
                <?php $_from = $this->_tpl_vars['de']['list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
                <tr>
                    <td><input type="checkbox" value="<?php echo $this->_tpl_vars['list']['id']; ?>
" class="checkitem" name="chk[]"></td>
                    <td><?php echo $this->_tpl_vars['list']['pid']; ?>
</td>
                    <td><?php echo $this->_tpl_vars['list']['sku_id']; ?>
</td>
                    <td><div ><img width="50" src="<?php echo $this->_tpl_vars['list']['pic']; ?>
"></div></td>
                    <td>
                    <a href="http://wx.52ywy.com/item-<?php echo $this->_tpl_vars['list']['pid']; ?>
.html" target="_blank"><?php echo $this->_tpl_vars['list']['pname']; ?>
</a></td>
                    <td><?php echo $this->_tpl_vars['list']['spec']; ?>
</td>
                    <td><?php echo ((is_array($_tmp=$this->_tpl_vars['list']['start_time'])) ? $this->_run_mod_handler('date_format', true, $_tmp, "%Y-%m-%d %H:%M") : smarty_modifier_date_format($_tmp, "%Y-%m-%d %H:%M")); ?>
 <br/> <?php echo ((is_array($_tmp=$this->_tpl_vars['list']['end_time'])) ? $this->_run_mod_handler('date_format', true, $_tmp, "%Y-%m-%d %H:%M") : smarty_modifier_date_format($_tmp, "%Y-%m-%d %H:%M")); ?>
<br />
                    <span <?php if ($this->_tpl_vars['list']['start_time'] <= ((is_array($_tmp=time())) ? $this->_run_mod_handler('date_format', true, $_tmp, '%Y-%m-%d %H:%M:%S') : smarty_modifier_date_format($_tmp, '%Y-%m-%d %H:%M:%S')) && ((is_array($_tmp=time())) ? $this->_run_mod_handler('date_format', true, $_tmp, '%Y-%m-%d %H:%M:%S') : smarty_modifier_date_format($_tmp, '%Y-%m-%d %H:%M:%S')) <= $this->_tpl_vars['list']['end_time']): ?>style="color:green">(进行中<?php elseif ($this->_tpl_vars['list']['start_time'] > ((is_array($_tmp=time())) ? $this->_run_mod_handler('date_format', true, $_tmp, '%Y-%m-%d %H:%M:%S') : smarty_modifier_date_format($_tmp, '%Y-%m-%d %H:%M:%S'))): ?>style="color:blue">(未开始<?php elseif ($this->_tpl_vars['list']['end_time'] < ((is_array($_tmp=time())) ? $this->_run_mod_handler('date_format', true, $_tmp, '%Y-%m-%d %H:%M:%S') : smarty_modifier_date_format($_tmp, '%Y-%m-%d %H:%M:%S'))): ?>style="color:red">(已过期<?php endif; ?>)</span>
                    </td>
                    <td><?php echo $this->_tpl_vars['list']['cat']; ?>
</td>
                    <td style="text-align:center"><?php echo $this->_tpl_vars['config']['money']; ?>
 <?php echo $this->_tpl_vars['list']['sec_price']; ?>
</td>
                    <td style="text-align:center"><?php echo $this->_tpl_vars['config']['money']; ?>
<?php echo $this->_tpl_vars['list']['price']; ?>
</td>
                    <td style="text-align:center"><?php echo $this->_tpl_vars['config']['money']; ?>
<?php echo $this->_tpl_vars['list']['market_price']; ?>
</td>
                    <td style="text-align:center"><?php echo $this->_tpl_vars['list']['sec_total']; ?>
</td>
                    <td style="text-align:center"><?php echo $this->_tpl_vars['list']['sec_true_stock']; ?>
</td>
                    <td style="text-align:center"><?php echo $this->_tpl_vars['list']['sec_stock']; ?>
</td>
                    <td style="text-align:center"><?php echo $this->_tpl_vars['list']['sec_limit']; ?>
</td>
                    <td style="text-align:center"><?php if ($this->_tpl_vars['list']['status'] == '1'): ?>开启<?php else: ?>关闭<?php endif; ?></td>
                    <td>
                    <a href="?m=activity&s=promote.php&operation=edit&editid=<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['editimg']; ?>
</a> 
                    <a onclick="return confirm('确定删除吗');" href="?m=activity&s=promote.php&delid=<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['delimg']; ?>
</a> 
                    <!--<?php if ($this->_tpl_vars['list']['catid'] == -1): ?><a href='?m=activity&s=activity_product_list.php&editid=<?php echo $this->_tpl_vars['list']['id']; ?>
'><?php echo $this->_tpl_vars['setimg']; ?>
<?php endif; ?></a>-->
                    </td>
                </tr>
                <?php endforeach; else: ?>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <?php endif; unset($_from); ?>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="99">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" value="删除" />
                    	<div class="page"><?php echo $this->_tpl_vars['de']['page']; ?>
</div>
                    	<a href="javascript:showProductIds('<?php echo $this->_tpl_vars['productIds']; ?>
');">导出产品ID</a>
                    </td>
                </tr>
            </tfoot>
                    </form>
        </table>

        <?php endif; ?>
    </div>
</body>
</html>